<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>HTTP GET 变量</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="reserved.variables.server.html">« $_SERVER</a></li>
      <li style="float: right;"><a href="reserved.variables.post.html">$_POST »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="reserved.variables.html">预定义变量</a></li>
    <li>HTTP GET 变量</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="reserved.variables.get" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">$_GET</h1>
  <p class="refpurpose"><span class="refname">$_GET</span> &mdash; <span class="dc-title">HTTP GET 变量</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-reserved.variables.get-description">
  <h3 class="title">说明</h3>
  <p class="para">
  通过 URL 参数（又叫 query string）传递给当前脚本的变量的数组。
   注意：该数组不仅仅对 method 为 GET 的请求生效，而是会针对所有带 query string 的请求。
  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-reserved.variables.get-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="variable.get.basic">
    <p><strong>示例 #1 <var class="varname">$_GET</var> 范例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">'Hello&nbsp;'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">htmlspecialchars</span><span style="color: #007700">(</span><span style="color: #0000BB">$_GET</span><span style="color: #007700">[</span><span style="color: #DD0000">"name"</span><span style="color: #007700">])&nbsp;.&nbsp;</span><span style="color: #DD0000">'!'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>
     假设用户访问的是 http://example.com/?name=Hannes
    </p></div>
    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Hello Hannes!
</pre></div>
    </div>
   </div>
  </p>
 </div>

 
 <div class="refsect1 notes" id="refsect1-reserved.variables.get-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">注意</strong>: <p class="para">“Superglobal”也称为自动化的全局变量。这就表示其在脚本的所有作用域中都是可用的。不需要在函数或方法中用
<strong class="command">global $variable;</strong> 来访问它。</p></p></blockquote>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    GET 是通过 <span class="function"><a href="function.urldecode.html" class="function">urldecode()</a></span> 传递的。
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-reserved.variables.get-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><a href="language.variables.external.html" class="link">处理外部变量</a></li>
    <li class="member"><a href="book.filter.html" class="link">过滤器扩展</a></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>